<?php
    require_once "../../config.php";
    require_once "../../functions.php";
    //获取前端传来的文章id
    $postId = $_POST["postId"];
    //连接数据库
    $connect = connect();
    //sql
    $delSql = "DELETE FROM posts WHERE id = {$postId}";
    //执行sql语句
    $result = mysqli_query($connect,$delSql);
    // 返回前端的信息提示
    $response = ["code"=>0,"msg"=>"操作失败"];
    //判断查询是否成功
    if($result){
        $response["code"] = 1;
        $response["msg"] = "操作成功";
        
    }
    header("content-type:application/json;charset=ut8");
    echo json_encode($response);
?>